package com.demo.config

import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import springfox.documentation.builders.ApiInfoBuilder
import springfox.documentation.builders.PathSelectors
import springfox.documentation.builders.RequestHandlerSelectors
import springfox.documentation.service.Contact
import springfox.documentation.spi.DocumentationType
import springfox.documentation.spring.web.plugins.Docket
import springfox.documentation.swagger2.annotations.EnableSwagger2

@Configuration
@EnableSwagger2
class SwaggerConfig {
    @Bean
    fun createRestApi(): Docket {
        return Docket(DocumentationType.SWAGGER_2)
                .apiInfo(
                        ApiInfoBuilder()
                                .title("YFree_SpringBoot")
                                .description("欢迎使用YFree_SpringBoot")
                                .termsOfServiceUrl("https://gitee.com/2425116357/YFree_SpringBoot.git")
                                .contact(Contact("YangZhe", "https://gitee.com/2425116357/YFree_SpringBoot.git", "2425116357@qq.com"))
                                .version("1.0.0")
                                .build()
                )
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.demo.controller"))
                .paths(PathSelectors.any())
                .build()
    }
}
